package com.ce.source.analysis.lifecycle.spring.code;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValues;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;

import java.beans.PropertyDescriptor;

/**
 * @author ：前世小和尚（xiaopingzhang8@creditease.cn）
 * @Description ：
 * @ClassName ：MyInstantiationAwareBeanPostProcessor
 * @Company ：普信恒业科技发展（北京）有限公司
 * @date ：2018/1/29 13:57
 */
public class MyInstantiationAwareBeanPostProcessor extends InstantiationAwareBeanPostProcessorAdapter {
    private static final Logger log = LoggerFactory.getLogger(MyInstantiationAwareBeanPostProcessor.class);

    public MyInstantiationAwareBeanPostProcessor() {
        super();
        log.info("InstantiationAwareBeanPostProcessorAdapter实现类构造器");
    }

    @Override
    public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
        log.info("InstantiationAwareBeanPostProcessorAdapter.postProcessBeforeInstantiation方法");
        return null;
    }

    @Override
    public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException {
        log.info("InstantiationAwareBeanPostProcessorAdapter.postProcessAfterInstantiation方法");
        return true;
    }

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        log.info("InstantiationAwareBeanPostProcessorAdapter.postProcessBeforeInitialization初始化之前");
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        log.info("InstantiationAwareBeanPostProcessorAdapter.postProcessAfterInitialization初始化之后");
        return bean;
    }

    @Override
    public PropertyValues postProcessPropertyValues(PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException {
        log.info("InstantiationAwareBeanPostProcessorAdapter.postProcessPropertyValues设置属性");
        return pvs;
    }
}
